package cn.gp.mapper;

import cn.gp.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName CategoryMapper.xml
 * @Description TODO
 * @Author He_Guoping
 * @Date 2023/5/27 15:50
 * @Version 1.0
 */
public interface CategoryMapper {

    @Select("select count(1) from category")
    Long count();

    @Select("select * from category limit #{page}, #{pageSize}")
    List<Category> page(@Param("page") Integer page, @Param("pageSize") Integer pageSize);

//    @Select("select id, name, create_time createTime, update_time updateTime from category")
//    @Select("select * from category")
    List<Category> list(String name);

    @Insert("insert into category(name) values(#{name});")
    void save(Category category);

    @Update("update category set name = #{name} where id = #{id};")
    void update(Category category);

    @Delete("delete from category where id = #{id};")
    void deleteById(Integer id);

    @Select("select * from category")
    List<Category> getCategoryList();
}
